package bid

import (
	"encoding/json"
	"github.com/golang/protobuf/proto"
	"wx-api/adx-bid/models/bid/BidModel"
)

type DHuayan struct{}

func (z *DHuayan) Req(p *BudgetService) (data []byte, hd map[string]string, surl, method string, tms int, err error) {
	surl = p.Dsp.BidUrl
	method = "POST"
	tms = 350
	hd = make(map[string]string)
	hd["Content-Type"] = "application/json"
	data, err = proto.Marshal(p.Req)
	return data, hd, surl, method, tms, err
}
func (z *DHuayan) Res(p *BudgetService, tmpbody []byte) (*BidModel.BidResponse_SeatBid_Bid, error) {
	m := &BidModel.BidResponse{}
	err := json.Unmarshal(tmpbody, m)
	if err != nil {
		return nil, err
	}
	tmpbid := m.GetSeatbid()[0].GetBid()[0]
	return tmpbid, nil
}
